package cn.johnyu;


import java.io.FileInputStream;
import java.io.InputStream;
import java.util.function.Consumer;

public class ContentReader {
    public void readFile(String fileName, Consumer<byte[]> consumer){
        try(InputStream inputStream=new FileInputStream(fileName);
            //2 lene
        ){
            byte[] buf=new byte[inputStream.available()];
            inputStream.read(buf);
            consumer.accept(buf);
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    public static void main(String[] args) {
        ContentReader reader = new ContentReader();
//        reader.readFile("abc.txt", new ResultFormatter() {``
//            @Override
//            public void format(byte[] buf) {
//                System.out.println(new String(buf));
//            }
//        });
        reader.readFile("abc.txt",buf-> System.out.println(new String(buf)));
//
       Consumer consumer= buf-> System.out.println(new String(new byte[]{1}));
        System.out.println(consumer.getClass().getName());
    }
}
